﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SmartXLS;

namespace ERP.Source.Utility
{
    public static class FileSystem
    {
        private static string fileName;
        private static WorkBook workBook;

        public static string FileName 
        {
            set 
            {
                fileName = value;
            }

            get
            {
                return fileName;
            }
        }
        
        public static WorkBook WorkBook
        {
            set
            {
                workBook = value;
            }
            get
            {
                return workBook;
            }
        }

        public static void ReadExcelFile()
        {
        }
               
        public static void WriteExcelFile(int row, int col)
        {
            int i = 0;
            int j = 0;
            try
            {
                workBook.setSheetName(0, "Bảng khối lượng");
                workBook.Sheet = 0;
                workBook.setText(65535, 0, "");

                for (i = 1; i < row; i++)
                {
                    for (j = 1; j < col; j++)
                    {
                        int text = Convert.ToInt32(i.ToString() + j.ToString());

                        workBook.setNumber(i, j, text);
                    }
                }

                workBook.write(fileName);
            }
            catch (Exception ex)
            {
                System.Console.Out.WriteLine(row);
                System.Console.Out.WriteLine(ex.Message);
            }

            //Message box confirmation to view the created spreadsheet.
            if (true)
            {
                //Launching the Excel file using the default Application.[MS Excel Or Free ExcelViewer]
                System.Diagnostics.Process.Start(fileName);
            }
            else
            {
            }
        }

        public static void ReadVMQFile()
        {
            //chua phan dinh kieu tra ve ^.^
        }

        public static void WriteVMQFile()
        {
            //chua phan dinh kieu tra ve ^.^
        }
    }
}
